#include "Gunner.h"
#include "Box.h"
#include "Sprite.h"
#include "RSManager.h"
#include "BulletManager.h"
Gunner::Gunner(Box* box): Object(box, ObjEnemy_STATIC)
{
}

void Gunner::init()
{
	_sprite= RSManager::getInstance()->getSprite(GUNNER);
	delay =0;
	gundelay=0;
	_hits=1;
	_isAlive =true;
	isGun=false;
}
void Gunner::update()
{
	delay+=GAME_TIME;
	gundelay+=GAME_TIME;
	if(gundelay>800)
	{
		gundelay=0;
		BulletManager::getInstance()->shoot(B_M,_obj, _box->_position+ D3DXVECTOR2(-10,45),M_PI);
		isGun =true;
	}
	if(delay>100 && isGun){
		delay=0;
		_sprite->Next();
		if(_sprite->_index ==0)
			isGun =false;
	}
	if(_hits<=0)
		_isAlive = false;
}
void Gunner::render()
{
	if(_isAlive)
	_sprite->Render(_box->_position);
}
Box* Gunner::getCollisionBox()
{
	_colBox->_position= _box->_position;
	_colBox->_size =_colBox->_size;
	_colBox->_v=_box->_v;
	return _colBox;
}
Gunner::~Gunner(void)
{
}
